{% extends 'layout.html' %}
{% load rbac %}

{% block content %}

    <div class="luffy-container">
        <div class="btn-group" style="margin: 5px 0">

            {% if request|has_permission:"rbac:permission_add" %}
            <a class="btn btn-default" href="{% url 'rbac:permission_add' %}">
                <i class="fa fa-plus-square" aria-hidden="true"></i> 添加权限
            </a>
            {% endif %}


        </div>
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>ID</th>
                <th>权限名称</th>
                <th>权限别名</th>
                <th>权限url</th>
                {% if request|has_permission:"rbac:permission_edit" or request|has_permission:"rbac:permission_delete" %}
                    <th>选项</th>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for row in data_list %}
                <tr>
                    <td>{{ row.id }}</td>
                    <td>{{ row.title }}</td>
                    <td>{{ row.name }}</td>
                    <td>{{ row.url }}</td>
                    {% if request|has_permission:"rbac:permission_edit" or request|has_permission:"rbac:permission_delete" %}
                        <td>
                            {% if request|has_permission:"rbac:permission_edit" %}
                            <a style="color: #333333;" href="{% url 'rbac:permission_edit' pk=row.id %}">
                                <i class="fa fa-edit" aria-hidden="true"></i></a>
                            {% endif %}

                            {% if request|has_permission:"rbac:permission_delete" %}
                                <a style="color: #d9534f;" href="{% url 'rbac:permission_delete' pk=row.id %}"><i class="fa fa-trash-o"></i></a>
                            {% endif %}
                        </td>
                    {% endif %}

                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}